package 传智播客_黑马.java基础.集合总览.Map.常用实现类;

import java.util.HashMap;
import java.util.LinkedHashMap;

/*
有序的集合
    底层原理 :
        哈希表 + 链表(记录元素的顺序)
 */
public class LearnLinkedHashMap {
    public static void main(String[] args) {
        HashMap<String, String> map = new HashMap<>();
        map.put("a","c");
        map.put("c","c");
        map.put("b","b");
        map.put("a","a");
        System.out.println(map);//key不允许重复,无序

        LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<>();
        linkedHashMap.put("a","c");
        linkedHashMap.put("c","c");
        linkedHashMap.put("b","b");
        linkedHashMap.put("a","a");
        System.out.println(linkedHashMap);//key不允许重复,但是有序
    }
}
